import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;

public class TreasureEnhancement {
    private static final int DEFAULT_LEVEL = 1;

    public static void main(String[] args) {
        int maxLevel = 12; // 最大强化等级
        double xpMulti = 1.5; // 每级强化需要的经验倍数

        Treasure treasure = new Treasure(10,xpMulti);
        enhanceTreasure(treasure, maxLevel, xpMulti,2048);
    }

    public static void enhanceTreasure(Treasure treasure, int maxLevel, double xpMulti,int xp) {
        int currentLevel = DEFAULT_LEVEL;

        while (currentLevel <= maxLevel) {
            double xpNeeded = treasure.getXpNeededForLevel(currentLevel, xpMulti);
            if (xpNeeded <= xp) {
                xp -= xpNeeded;
                currentLevel++;
                System.out.println("Treasure enhanced to level " + currentLevel);
            } else {
                System.out.println("Insufficient experience to enhance to the next level.");
                break;
            }
        }
    }

    public static class Treasure {

        private final double startXp;
        private final double xpMulti;

        public Treasure(double startXp, double xpMulti) {
            this.startXp = startXp;
            this.xpMulti = xpMulti;
        }

        public double getXpNeededForLevel(int level, double xpMulti) {
            return startXp * Math.pow(xpMulti, level - 1);
        }
    }
}


